/*
 *****************************************************************************
 * Copyright (C) 2005-2011 UC Mobile Limited. All Rights Reserved
 * File			: AutomatedItemPage.m
 *
 * Description	: 常用自动化测试项目页面
 *
 * Author		: daijb@ucweb.com
 * History		:
 *			   Creation, 2014/03/14, daijb, Create the file
 ******************************************************************************
 **/
#if defined(UC_COMMON_AUTOMATED_TEST) || defined(UC_MONKEY_TEST)
#import "VerDefine.h"

#import "AutomatedItemPage.h"
#import "AutomatedItemDataProcessor.h"
#import "AutomatedItemDataProvider.h"
#import "AutomatedMenuPage.h"
#import "AutomatedSettingPage.h"
#import "AutomatedActionsPage.h"

@implementation AutomatedItemPage

- (id)initWithTitle:(NSString *)title
{
    if (self = [super initWithTitle:title])
	{
        self.dataProvider = [[[AutomatedItemDataProvider alloc] init] autorelease];
        self.dataProcessor = [[[AutomatedItemDataProcessor alloc] init] autorelease];
        self.dataProcessor.delegate = self;
    }
    
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = resGetText(@"CommonAutomatedTest/Title");
    UIBarButtonItem* buttonItem = [[[UIBarButtonItem alloc] initWithTitle:resGetText(@"CommonAutomatedTest/Exit") style:UIBarButtonItemStylePlain target:self action:@selector(didCloseViewController)] autorelease];
    buttonItem.accessibilityLabel = @"exitAutomatedTest";
    self.navigationItem.leftBarButtonItem = buttonItem;
}

- (void)showSubViewWithTitle:(NSString*)title
{
    UIViewController* viewController = nil;
    if ([title isEqualToString:resGetText(@"CommonAutomatedTest/Menu")])
    {
        viewController = [[AutomatedMenuPage alloc] initWithTitle:resGetText(@"CommonAutomatedTest/Menu")];
    }
    else if([title isEqualToString:resGetText(@"CommonAutomatedTest/Setting")])
    {
        viewController = [[AutomatedSettingPage alloc] initWithTitle:resGetText(@"CommonAutomatedTest/Setting")];
    }
    else if ([title isEqualToString:@"常规操作"])
    {
        viewController = [[AutomatedActionsPage alloc] initWithTitle:@"常规操作"];
    }
    
    if (viewController)
    {
        [self.navigationController pushViewController:viewController animated:YES];
        [viewController release];
    }
}

#pragma mark - close

- (void)didCloseViewController
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
#endif
